<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Home Page</title>
    <link href="Styles/style.css" rel="stylesheet" type="text/css" />

</head>
<body>     
<?php
	session_start();
	if(isset($_SESSION['message']))
	{
		echo $_SESSION['message'];
		$_SESSION['message']=null;
	}
	include ("database/DataProvider.php");
	require('class/paginator.php');
	include 'buynow.php';
?>               
<table width="996"  border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td height="607" valign="top">
<!-- top -->
		 	<table width="996"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="285" height="52">
                     <a href="#"><img src="images/logo.jpg" alt="" width="415" height="52" border="0"></a>
                    </td>
                    <td width="711" class="menu">
                    <?php
                        include('menu_top.php');
                    ?>                             									
                	</td>
             	</tr>
             </table>
<!--Shop cart-->		
            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="60%" height="66" align="left" valign="top">
                      <table width="597"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td><img src="images/afterlogo.jpg" width="597" height="38"></td>
                        </tr>
                        <tr>
                          <td height="28" class="slide">
                              <table width="597"  border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td width="76" height="14">&nbsp;</td>
                                  
                                  <td width="18">&nbsp;</td>
                                </tr>
                              </table>
                          </td>
                        </tr>
                      </table>
                  </td>
                  <td width="40%">
                      <table width="399"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="157">&nbsp;</td>
                          <td width="58">
                            	<img src="images/trash.jpg" alt="" width="47" height="48" border="0">
                          </td>
                          <td width="184"><span class="style6">Giỏ hàng: <?php if(isset($_SESSION['fullname'])) echo $_SESSION['fullname']; ?></span> <br>
                            <a href="?view=viewCart"><span class="style7">
                            <?php
                             	if(isset($_SESSION['cart'])){ 
									echo ("Xem " . count($_SESSION['cart']) . " Sản phẩm <br> Bạn đã chọn mua."); 
                             	} 
                            ?></span></a>
                            </td>
                        </tr>
                      </table>
                  </td>
                </tr>
            </table>
<!-- Banner-->	
			<table width="996"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td>
                     <a href="#">
                      <img src="images/banner1.jpg" alt="" width="996" height="300" border="0" />
                     </a>
                    </td>
                </tr>
            </table>
<!--middle-->	
            <table width="996"  border="0" cellspacing="0" cellpadding="0">
            	<?php 
					if(!isset($_SESSION["fullname"]))					
					{
						echo "<tr><td align=center colspan=4><div style='font-size: large;'><b>Welcome: Guest!</b>&nbsp;<a href=?show=login>Sign in</a>&nbsp; | &nbsp;<a href='index.php?show=register_form'>Register</a>&nbsp; | &nbsp;<a href='./admin/index.php'> CP Admin</a></div></td></tr>";
					}
					else
					{
            			echo "<tr><td align=center colspan=4><div style='font-size: large;'><b>Welcome: ".$_SESSION["fullname"]."</b>&nbsp; | &nbsp;<a href=logout.php>Sign out</a>&nbsp; | &nbsp;<a href='./admin/index.php'> CP Admin</a></div></td></tr>";
					}
					 
				?>
                <tr align="left" valign="top">
                    <td width="202" height="334">
<!--left menu-->					
						<?php
							
                            include ('menu_cat.php');
							include ('menu_manu.php');
							include ('search.php');
                        ?> 
                        
                    </td>
                    <td width="20">&nbsp;</td>
                    <td width="774">
<!--main containt--> 
                        <table width="774"  border="0" cellspacing="0" cellpadding="0">                              
                          <tr>
                            <td height="479">&nbsp;</td>
                            <td align="left" valign="top">          
						<?php
                        
                        $txtname		=	$_REQUEST['txtname'];
                        $txtpricefrom	=	$_REQUEST['txtpricefrom'];
                        $txtpriceto		=	$_REQUEST['txtpriceto'];
                        $manu			=	$_REQUEST['manu'];
                        $cat			=	$_REQUEST['cat'];
                        
                        $cond	="";
                        $cond	.=($txtname !="")?" AND TenSanPham=".$txtname:"";
                        $cond	.=($txtpricefrom !="")?" AND GiaSanPham >= ".$txtpricefrom:"";
                        $cond	.=($txtpriceto !="")?" AND GiaSanPham <=".$txtpriceto:"";
                        $cond	.=($manu !="all")?" AND MaHangSanXuat=".$manu:"";
                        $cond	.=($cat !="all")?" AND MaLoaiSanPham=".$cat:"";	
                        $query = "select * from sanpham where BiXoa=0".$cond;
                        
                        $result = DataProvider::ExecuteQuery($query);
                                                    
                        ?>
                 
                        <div>
                        <?php
                        // Tìm kiếm cơ bản
                        $product = new paginator();
                        $product::display($result);
                        
                        ?>
                     </div>
                    </td>
                 </tr>
                </table>
                
                </td>
                            <td>&nbsp;</td>
                         </tr>
                        </table>
                    </td>
                </tr>
              </table>
					  
<!--footer-->  
				<?php
                    include('footer.php');
                ?>  
  </td>
 </tr>
</table>
</body>
</html>

